package algorithm.structure.tree.common;

import algorithm.structure.tree.inter.BaseNodeSYT;

public class NodeSYT implements BaseNodeSYT{
	private NodeSYT leftChild;
	private NodeSYT rightChild;
	private NodeSYT parent;
	private NodeKeySYT nodeKey;
	
	public NodeSYT getLeftChild() {
		return leftChild;
	}
	public void setLeftChild(NodeSYT leftChild) {
		this.leftChild = leftChild;
	}
	public NodeSYT getRightChild() {
		return rightChild;
	}
	public void setRightChild(NodeSYT rightChild) {
		this.rightChild = rightChild;
	}
	public NodeSYT getParent() {
		return parent;
	}
	public void setParent(NodeSYT parent) {
		this.parent = parent;
	}
	
	public NodeKeySYT getNodeKey() {
		return nodeKey;
	}
	public void setNodeKey(NodeKeySYT nodeKey) {
		this.nodeKey = nodeKey;
	}
	public void clear(){
		if(this.parent != null){
			if(this.parent.getLeftChild() == this){
				this.parent.setLeftChild(null);
			}else{
				this.parent.setRightChild(null);
			}
		}
		if(leftChild != null){
			leftChild.setParent(null);
		}
		if(rightChild != null){
			rightChild.setParent(null);
		}
		leftChild = null;
		rightChild = null;
		parent = null;
	}
	public boolean isNil() {
		return false;
	}
}
